#include <gnome.h>

static GtkWidget *s_app = NULL;

void str_cb(gchar *string,gpointer data){
	if(!string)
		g_print("string == NULL\n");
	else if(strlen(string) == 0)
		g_print("string len is 0\n");
	else
		g_print("GOT : %s\n",string);
}

void yes_or_no(gint reply,gpointer data){
	if(reply == GNOME_YES)
		g_print("The answer is YES\n");
	else
		g_print("The answer is NO\n");
}

void click_handle(GtkWidget *self,gpointer data){
	g_print("%s enter!\n",__func__);
	GtkWidget *dialog = gnome_question_dialog_modal_parented("Do you love me?",
		(GnomeReplyCallback)yes_or_no,NULL,GTK_WINDOW(s_app));
}

int main(int argc,char **argv){
	GtkWidget *btn;

	gnome_init("dialog","1.0",argc,argv);
	s_app = gnome_app_new("dialog","Question dialog");
	gtk_window_set_position(GTK_WINDOW(s_app),GTK_WIN_POS_CENTER_ALWAYS);
	btn = gtk_button_new_with_label("press me!");
	gtk_signal_connect(GTK_OBJECT(btn),"clicked",G_CALLBACK(click_handle),NULL);
	gtk_signal_connect_object(GTK_OBJECT(s_app),"destroy",G_CALLBACK(gtk_main_quit),NULL);
	gtk_container_set_border_width(GTK_CONTAINER(s_app),30);
	gnome_app_set_contents(GNOME_APP(s_app),btn);
	gtk_widget_show_all(s_app);

	GtkWidget * d = gnome_request_string_dialog("Lover Name : ",(GnomeStringCallback)str_cb,NULL);
	gtk_window_set_modal(GTK_WINDOW(d),TRUE);

	gtk_main();
	return 0;
}